<template>
  <a-descriptions title="TRANSACTION RECEIPT" bordered :column="1">
    <a-descriptions-item label="交易HASH">
      {{ receipt.transactionHash }}
      <a-icon type="copy" @click="copy(receipt.transactionHash)"/>
    </a-descriptions-item>
    <a-descriptions-item label="交易索引">
      {{ receipt.transactionIndex }}
    </a-descriptions-item>
    <a-descriptions-item label="区块高度">
      {{ receipt.blockNumber }}
    </a-descriptions-item>
    <a-descriptions-item label="区块HASH">
      {{ receipt.blockHash }}
      <a-icon type="copy" @click="copy(receipt.blockHash)"/>
    </a-descriptions-item>
    <a-descriptions-item label="发送方">
      {{ receipt.from }}
      <a-icon type="copy" @click="copy(receipt.from)"/>
    </a-descriptions-item>
    <a-descriptions-item label="接收方">
      {{ receipt.to }}
      <a-icon type="copy" @click="copy(receipt.to)" v-if="receipt.to"/>
    </a-descriptions-item>
    <a-descriptions-item
      label="合同地址"
      v-if="receipt.contractAddress">
      {{ receipt.contractAddress }}
      <a-icon type="copy" @click="copy(receipt.contractAddress)"/>
    </a-descriptions-item>
  </a-descriptions>
</template>

<script>
import Constant from "../utils/Constant";
export default {
  props: ["receipt"],
  created() {
    console.log(this.receipt);
  },
  methods: {
    copy(data) {
      console.log("copy", data)
      Constant.copyToClipboard(data, () => {
         this.$message.success(data + " Copied!")
      });
    },
  }
};
</script>
